<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加电影</title>
	<style type="text/css">
		table{
			margin: auto;
			border: black solid 0px;
			border-collapse: collapse;
		}
		td{
			padding: 10px;
			border: black solid 0px;
		}
	</style>
	<script type="text/javascript" src="${pageContext.request.contextPath}/3rd/jquery/jquery-3.4.1.min.js"></script>
	<script type="text/javascript" >
		function findname(){
			var inputNode = document.getElementById("name");
			var spanNode = document.getElementById("s");
			var sendData = {name : inputNode.value};
			var url = "${pageContext.request.contextPath}/user?action=find&id=" + new Date().getTime();
			$.post(url,sendData,function(backDate){
					if(backDate == "true"){
						spanNode.innerHTML = "√".fontcolor("green");
					}else{
						spanNode.innerHTML = "用户名已存在".fontcolor("red");
					}
				}
			);
		}
	</script>
</head>
<body>
	<table>
		<form action="${pageContext.request.contextPath}/user?action=add&flag=1" method="post">
			<caption><h1>添加管理员</h1></caption>
			<tr>
				<td align="right">管理员名:</td>
				<td><input type="text" name="name" id="name" onblur="findname()"><span id="s"></span></td>
			</tr>
			<tr>
				<td align="right">密码:</td>
				<td><input type="text" name="password"></td>
			</tr>
			<tr>
				<td align="right">电话号码:</td>
				<td><input type="text" name="phone"></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input type="submit" value="提交"></td>
			</tr>
		</form>
	</table>
</body>
</html>